package com.yanqu.road.server.cmd.activity.gourdchild;

import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.activity.GourdChildProto;
import com.yanqu.road.pb.player.PlayerProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.gourdchild.CrossGourdChildMgr;
import com.yanqu.road.server.manager.gourdchild.GourdChildActivity;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_GOURD_CHILD_ACTIVITY_UPLOAD_NOTICE, desc = "公告上传")
public class CrossGourdChildUploadNoticeCmd extends CrossCommand {

    int activityId;
    PlayerProto.PlayerBaseTempMsg player;
    int goodsId;
    long playerId;
    int type;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        GourdChildProto.CrossGourdChildUploadNoticeReqMsg reqMsg = GourdChildProto.CrossGourdChildUploadNoticeReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        player = reqMsg.getPlayer();
        goodsId = reqMsg.getGoodsId();
        playerId = packet.getPlayerId();
        type = reqMsg.getType();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        GourdChildActivity activity = CrossGourdChildMgr.getGourdChildActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_GOURD_CHILD_ACTIVITY_NO_OPEN;
            return;
        }

        activity.uploadNotice(playerId, goodsId, PlayerBasePb.parseToUserBaseInfo(player), type);
    }

    @Override
    public void sendData() {

    }
}
